const wx2my = require('../../../wx2my');
const Behavior = require('../../../Behavior');
var _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
  return typeof o;
} : function (o) {
  return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
},
    siteinfo = require("../../../siteinfo.js"),
    app = getApp();

Page({
  data: {
    arrays: ["暂无星级(经济型)", "三星级", "四星级", "五星级"],
    index: 0,
    inde: 0,
    prompt: !1,
    choice: !0,
    getmsg: "获取验证码",
    interval: "interval2",
    num: 0,
    store_num: 1
  },
  onLoad: function (o) {
    this.setData({
      color: wx2my.getStorageSync("platform").color
    }), wx2my.setNavigationBarColor({
      frontColor: '#000000',
      backgroundColor: '#ffffff'
    }), console.log(_typeof("a"));
    var e = wx2my.getStorageSync("openid"),
        t = wx2my.getStorageSync("users").id,
        a = wx2my.getStorageSync("platform"),
        n = wx2my.getStorageSync("url");
    console.log("用户的openid为 " + e + " 用户的user_id为 " + t), this.setData({
      user_id: t,
      url: n,
      system: a
    });
  },
  choose_address: function (o) {
    var t = this;
    wx2my.chooseLocation({
      success: function (o) {
        console.log(o);
        var e = o.latitude + "," + o.longitude;
        console.log(e), t.setData({
          address: o.address,
          latitude: e
        });
      }
    });
  },
  bindPickerChanges: function (o) {
    this.setData({
      index: o.detail.value
    });
  },
  choose: function (o) {
    var t = this,
        a = siteinfo.siteroot,
        n = siteinfo.uniacid,
        l = o.currentTarget.dataset.id;
    console.log(l);
    wx2my.chooseImage({
      count: 1,
      sizeType: ["original", "compressed"],
      sourceType: ["album", "camera"],
      success: function (o) {
        console.log(o);
        var e = o.tempFilePaths[0];
        wx2my.uploadFile({
          url: a + "?i=" + n + "&c=entry&a=wxapp&do=upload&m=zh_jdgjb",
          filePath: e,
          name: "upfile",
          formData: {},
          success: function (o) {
            console.log("这是上传成功"), console.log(o), 1 == l ? t.setData({
              upload_one: o.data
            }) : 2 == l ? t.setData({
              upload_two: o.data
            }) : 3 == l && t.setData({
              upload_three: o.data
            });
          },
          fail: function (o) {
            console.log("这是上传失败"), console.log(o);
          }
        });
      }
    });
  },
  user_tel: function (o) {
    this.setData({
      phone: o.detail.value
    });
  },
  sendmessg: function (o) {
    var e = this;
    console.log(e.data);
    var t = e.data.phone;
    if ("" == t || null == t) wx2my.showToast({
      title: "请输入手机号",
      icon: "",
      image: "",
      duration: 2e3,
      mask: !0,
      success: function (o) {},
      fail: function (o) {},
      complete: function (o) {}
    });else {
      for (var a = "", n = 0; n < 6; n++) a += Math.floor(10 * Math.random());

      console.log(a), app.util.request({
        url: "entry/wxapp/sms2",
        cachetime: "0",
        data: {
          code: a,
          tel: t,
          type: 1
        },
        success: function (o) {
          console.log(o);
        }
      }), e.setData({
        num: a
      });
      var l = 59,
          s = setInterval(function () {
        e.setData({
          getmsg: l + "s后重新发送",
          send: !0
        }), --l <= 0 && (clearInterval(s), e.setData({
          getmsg: "获取验证码",
          send: !1,
          num: 0
        }));
      }, 1e3);
    }
  },
  verification_code: function (o) {
    var e = o.detail.value,
        t = this.data.num;
    6 == e.length && e != t && (wx2my.showModal({
      title: "",
      content: "验证码输入错误"
    }), this.setData({
      phone: 0
    }));
  },
  getPhoneNumber: function (o) {
    var e = this;
    console.log(app.getSK), console.log(o), app.util.request({
      url: "entry/wxapp/jiemi",
      cachetime: "0",
      data: {
        sessionKey: app.getSK,
        iv: o.detail.iv,
        data: o.detail.encryptedData
      },
      success: function (o) {
        console.log("这是解密手机号"), console.log(o), e.setData({
          phone: o.data.phoneNumber
        });
      }
    });
  },
  formSubmit: function (o) {
    var e = this;
    console.log(o);
    var t = e.data.store_num,
        a = o.detail.value.hotel_name,
        n = o.detail.value.hotel_address,
        l = e.data.latitude;
    l = String(l);
    var s = o.detail.value.hotel_contacts,
        i = o.detail.value.hotel_tel,
        c = e.data.upload_one,
        r = e.data.upload_two,
        u = e.data.upload_three,
        d = o.detail.value.textarea,
        g = e.data.arrays[e.data.index],
        f = e.data.phone,
        p = wx2my.getStorageSync("userInfo").id;
    console.log("酒店名称 " + a), console.log("酒店地址 " + n), console.log("酒店地址 " + l), console.log("酒店联系人姓名 " + s), console.log("酒店联系人电话 " + i), console.log("图片1 " + c), console.log("图片2 " + r), console.log("图片3 " + u), console.log("补充说明 " + d), console.log("酒店星级 " + g);
    var m = "";
    "" == a ? m = "请输入酒店名称" : "" == n ? m = "请选择酒店地址" : "" == s ? m = "请输入酒店联系人姓名" : "" == i ? m = "请输入酒店电话" : null == c ? m = "请上传营业执照" : null == r ? m = "请上传负责人身份证正面照片" : null == u ? m = "请上传负责人身份证反面照片" : "" == f || 0 == f ? m = "请进行手机号验证" : "" == d && (d = ""), "" != m ? wx2my.showModal({
      title: "",
      content: m
    }) : "" == m && 1 == t && (e.setData({
      store_num: 0
    }), app.util.request({
      url: "entry/wxapp/SaveHotelApply",
      cachetime: "0",
      data: {
        user_id: p,
        name: a,
        address: n,
        coordinates: l,
        link_name: s,
        link_tel: i,
        tel: f,
        sfz_img1: r,
        sfz_img2: u,
        yy_img: c,
        other: d,
        star: g
      },
      success: function (o) {
        console.log(o), 1 == o.data ? (wx, wx2my.showToast({
          title: "入驻成功"
        }), setTimeout(function () {
          wx2my.navigateBack({
            delta: 1
          });
        }, 1500)) : wx2my.navigateBack({
          delta: 1
        });
      },
      fail: function (o) {
        wx2my.showToast({
          title: "入驻失败"
        }), setTimeout(function (o) {
          wx2my.navigateBack({
            delta: 1
          });
        }, 1500);
      }
    }));
  },
  reset: function (o) {},
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
  onShareAppMessage: function () {}
});